<?php
// +----------------------------------------------------------------------
// Csmmeet [ Csmonline ]
// Author: chensm <chenshiming0802@163.com>
// Create by chensm at 2020-03-31
// +----------------------------------------------------------------------
namespace app\admin\controller\csmonline;

use app\common\controller\Backend;
use addons\csmonline\library\CsmBackend;

/**
 * 会员IP信息
 *
 * @icon fa fa-circle-o
 */
class Fauser extends CsmBackend
{

    /**
     * Fauser模型对象
     *
     * @var \app\admin\model\csmonline\Fauser
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\csmonline\Fauser();
    }

    public function index()
    {
        //设置过滤方法
        $this->request->filter(['strip_tags']);
        if ($this->request->isAjax()) {
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('keyField')) {
                return $this->selectpage();
            }
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $total = $this->model->alias('user')
            ->where($where)
            ->order($sort, $order)
            ->count();
            
            $list = $this->model
            ->where($where)
            ->order($sort, $order)
            ->limit($offset, $limit)
            ->select();
            
            $this->convertListColumn($list,'user_id',new \app\common\model\User(),'username');
            
            $list = collection($list)->toArray();
            $result = array("total" => $total, "rows" => $list);
            
            return json($result);
        }
        return $this->view->fetch();
    }
}

